var config = require('config-lite')(__dirname);
var Mongolass = require('mongolass');
var mongolass = new Mongolass();
mongolass.connect(config.mongodb);

exports.User = mongolass.model('User', {
    name: {type: 'string'},
    password: {type: 'string'},
    sex: {type: 'string'},
    photo: {type: 'string'},
    idCard: {type: 'string'},
    SA: {type: 'string'},
    email: {type: 'string'},
    admin: {type: 'number'}, //0普通用户，1会员，2店主，3管理员。
    createdAt: {type: 'string'}
});
exports.User.index({name: 1}, {unique: true}).exec();// 根据用户名找到用户，用户名全局唯一

exports.Goods = mongolass.model('Goods', {
    user: {type: Mongolass.Types.ObjectId},
    name: {type: 'string'},
    image: {type: Array},
    price: {type: 'number'},
    info: [
        {
            count: {type: 'number'},
            size: {type: "string"}
        }
    ],
    describe: {type: 'string'},
    createdAt: {type: 'string'},
    updatedAt: {type: 'string'}
});
exports.Goods.index({name: 1}).exec();

exports.Ueditor = mongolass.model('Ueditor', {
    goodsId: {type: Mongolass.Types.ObjectId},
    images: {type: Array},
    video: {type: Array}
});
exports.Ueditor.index({goodsId: 1}).exec();



